package com.hk;

import com.hk.impl.RentImpl;
import com.hk.invocation.MyInvocationHandler;

import java.lang.reflect.Proxy;

public class MainTest {
    public static void main(String[] args) {
        System.getProperties().put("sun.misc.ProxyGenerator.saveGeneratedFiles","true");

        //        目标类
        Rent rent=new RentImpl();
        MyInvocationHandler handler=new MyInvocationHandler(rent);

        Rent instance = (Rent) Proxy.newProxyInstance(rent.getClass().getClassLoader(),
                rent.getClass().getInterfaces(), handler);
        System.out.println(instance.getClass());
//        instance.rentHouse();
        int i=instance.rentCar(2,1);
        System.out.println("结果是======"+i);




    }
}
